/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/*
 * @(#)DBMetaClient7.java	1.16 02/01/12
 */

package jdbcts.dbMeta.dbMeta7;

import java.io.*;
import java.util.*;

import java.sql.*;
import javax.sql.*;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import com.sun.cts.util.*;
import com.sun.cts.porting.*;
import com.sun.cts.harness.*;

import java.rmi.RemoteException;

import javasoft.sqe.javatest.Status;
import jdbcts.SuperTest;
import jdbcts.common.DataSourceConnection;
import jdbcts.common.DriverManagerConnection;
import jdbcts.common.dbSchema;

import com.sun.cts.tests.jdbc.ee.common.*;

// Merant DataSource class
//import com.merant.sequelink.jdbcx.datasource.*;

/**
 * The DBMetaClient7 class tests methods of DatabaseMetaData interface using
 * Sun's J2EE Reference Implementation.
 * 
 * @author
 * @version 1.7, 06/16/99
 */

public class DBMetaClient7 extends SuperTest implements Serializable
{
    private static final String testName = "jdbc.ee.dbMeta.dbMeta7";

    // Naming specific member variables
    private CTSNamingContextInterface jc = null;

    // Harness requirements

    private transient static Connection conn = null;

    private transient static DatabaseMetaData dbmd = null;

    private DataSource ds1 = null;

    private static dbSchema dbSch = null;

//    private String dbName = null, dbUser = null, drManager = null;
    private static String drManager = null;

//    private String sCatalogName = null, sSchemaName = null, sPtable = null,
//	    sFtable = null;

    /* Run test in standalone mode */
//    public static void main(String[] args)
//    {
//	DBMetaClient7 theTests = new DBMetaClient7();
//	Status s = theTests.run(args, System.out, System.err);
//	s.exit();
//    }

    /* Test setup: */
    /*
     * @class.setup_props: Driver, the Driver name; db1, the database name with
     * url; user1, the database user name; password1, the database password;
     * db2, the database name with url; user2, the database user name;
     * password2, the database password; DriverManager, flag for DriverManager;
     * ptable, the primary table; ftable, the foreign table; cofSize, the
     * initial size of the ptable; cofTypeSize, the initial size of the ftable;
     * binarySize, size of binary data type; varbinarySize, size of varbinary
     * data type; longvarbinarySize, size of longvarbinary data type;
     * 
     * @class.testArgs: -ap ctssql.stmt
     */
    @BeforeClass
//    public void setup(String[] args, Properties p) throws Exception
    public static void setup() throws Exception
    {
	try
	{
	    try
	    {
//		drManager = p.getProperty("DriverManager", "");
		drManager = isDRManager;
//		dbName = p.getProperty("db1", "");
//		dbUser = p.getProperty("user1", "");
//		sPtable = p.getProperty("ptable", "CTSTABLE1");
//		sFtable = p.getProperty("ftable", "CTSTABLE2");
//		if (dbName.length() == 0)
//		    throw new Exception("Invalid db1  Database Name");
//		if (dbUser.length() == 0)
//		    throw new Exception("Invalid Login Id");
//		if (sPtable.length() == 0)
//		    throw new Exception("Invalid Primary table");
//		if (sFtable.length() == 0)
//		    throw new Exception("Invalid Foreign table");
		if (drManager.length() == 0)
		    throw new Exception("Invalid DriverManager Name");

//		int nLocdbname = dbName.indexOf('=');
//		sCatalogName = dbName.substring(nLocdbname + 1);
//		sCatalogName = sCatalogName.trim();
//		sSchemaName = dbUser;
		if (drManager.equals("yes"))
		{
		    logMsg("Using DriverManager");
		    DriverManagerConnection dmCon = new DriverManagerConnection();
//		    conn = dmCon.getConnection(p);
		    conn = dmCon.getConnection(null);
		}
		else
		{
		    logMsg("Using DataSource");
		    DataSourceConnection dsCon = new DataSourceConnection();
//		    conn = dsCon.getConnection(p);
		    conn = dsCon.getConnection(null);
		}
		dbSch = new dbSchema();
//		dbSch.createData(p, conn);
		dbmd = conn.getMetaData();
	    }
	    catch (SQLException ex)
	    {
		logErr("SQL Exception : " + ex.getMessage());
	    }
	}
	catch (Exception e)
	{
	    logErr("Setup Failed!");
	    TestUtil.printStackTrace(e);
	}
    }

    /*
     * @testName: testSupportsUnionAll
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The supportsUnionAll()
     * method must return a boolean value true if the database supports SQL
     * Union All and false otherwise. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsUnionAll() method on that object. It should
     * return a boolean value; eithet true or false.
     */
    @Test
    public void testSupportsUnionAll() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsUnionAll");
	    // invoke supportsUnionAll method
	    boolean retValue = dbmd.supportsUnionAll();
	    if (retValue)
		logMsg("supportsUnionAll is supported");
	    else
		logMsg("supportsUnionAll is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception("Call to supportsUnionAll is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to supportsUnionAll is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsOpenCursorsAcrossCommit
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsOpenCursorsAcrossCommit() method must return a boolean value;
     * true if cursors always remain open after commits; false if cursors are
     * closed on commit. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsOpenCursorsAcrossCommit() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsOpenCursorsAcrossCommit() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsOpenCursorsAcrossCommit");
	    // invoke supportsOpenCursorsAcrossCommit method
	    boolean retValue = dbmd.supportsOpenCursorsAcrossCommit();
	    if (retValue)
		logMsg("supportsOpenCursorsAcrossCommit is supported");
	    else
		logMsg("supportsOpenCursorsAcrossCommit is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsOpenCursorsAcrossCommit is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsOpenCursorsAcrossCommit is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsOpenCursorsAcrossRollback
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsOpenCursorsAcrossRollback() method must return a boolean value;
     * true if cursors always remain open after rollbacks; false if cursors are
     * closed on rollback. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsOpenCursorsAcrossRollback() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsOpenCursorsAcrossRollback() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsOpenCursorsAcrossRollback");
	    // invoke supportsOpenCursorsAcrossRollback method
	    boolean retValue = dbmd.supportsOpenCursorsAcrossRollback();
	    if (retValue)
		logMsg("supportsOpenCursorsAcrossRollback is supported");
	    else
		logMsg("supportsOpenCursorsAcrossRollback is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsOpenCursorsAcrossRollback is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsOpenCursorsAcrossRollback is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsOpenStatementsAcrossCommit
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsOpenStatementsAcrossCommit() method must return a boolean value;
     * true if statements always remain open after commits; false if statements
     * are closed on commit. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsOpenStatementsAcrossCommit() method on that
     * object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsOpenStatementsAcrossCommit() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsOpenStatementsAcrossCommit");
	    // invoke supportsOpenStatementsAcrossCommit method
	    boolean retValue = dbmd.supportsOpenStatementsAcrossCommit();
	    if (retValue)
		logMsg("supportsOpenStatementsAcrossCommit is supported");
	    else
		logMsg("supportsOpenStatementsAcrossCommit is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsOpenStatementsAcrossCommit is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsOpenStatementsAcrossCommit is Failed!", e);
	}
    }

    /*
     * @testName: testSupportsOpenStatementsAcrossRollback
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * supportsOpenStatementsAcrossRollback() method must return a boolean
     * value; true if statements always remain open after rollbacks; false if
     * statements are closed on rollback. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the supportsOpenStatementsAcrossRollback() method on
     * that object. It should return a boolean value; either true or false.
     */
    @Test
    public void testSupportsOpenStatementsAcrossRollback() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.supportsOpenStatementsAcrossRollback");
	    // invoke supportsOpenStatementsAcrossRollback method
	    boolean retValue = dbmd.supportsOpenStatementsAcrossRollback();
	    if (retValue)
		logMsg("supportsOpenStatementsAcrossRollback is supported");
	    else
		logMsg("supportsOpenStatementsAcrossRollback is not supported");
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception(
		    "Call to supportsOpenStatementsAcrossRollback is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception(
		    "Call to supportsOpenStatementsAcrossRollback is Failed!",
		    e);
	}
    }

    /*
     * @testName: testGetMaxBinaryLiteralLength
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getMaxBinaryLiteralLength() method must return a integer value; the value
     * representing the maximum number of hex characters; 0 if there is no limit
     * or the limit is unknown. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxBinaryLiteralLength() method on that object.
     * It should return an integer value
     */
    @Test
    public void testGetMaxBinaryLiteralLength() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxBinaryLiteralLength");
	    // invoke getMaxBinaryLiteralLength method
	    int nRetval = dbmd.getMaxBinaryLiteralLength();
	    if (nRetval < 0)
		logErr("getMaxBinaryLiteralLength returns a negative value");
	    else
		logMsg("getMaxBinaryLiteralLength returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxBinaryLiteralLength is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxBinaryLiteralLength is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxCharLiteralLength
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getMaxCharLiteralLength() method must return a integer value; the value
     * representing the maximum number of characters; 0 if there is no limit or
     * the limit is unknown. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxCharLiteralLength() method on that object. It
     * should return an integer value.
     */
    @Test
    public void testGetMaxCharLiteralLength() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxCharLiteralLength");
	    // invoke getMaxCharLiteralLength method
	    int nRetval = dbmd.getMaxCharLiteralLength();
	    if (nRetval < 0)
		logErr("getMaxCharLiteralLength returns a negative value");
	    else
		logMsg("getMaxCharLiteralLength returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxCharLiteralLength is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxCharLiteralLength is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxColumnNameLength
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getMaxColumnNameLength() method must return a integer value; the value
     * representing the maximum number of characters allowed as column name
     * length; 0 if there is no limit or the limit is unknown. (See JDK 1.2.2
     * API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxColumnNameLength() method on that object. It
     * should return an integer value
     */
    @Test
    public void testGetMaxColumnNameLength() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxColumnNameLength");
	    // invoke getMaxColumnNameLength method
	    int nRetval = dbmd.getMaxColumnNameLength();
	    if (nRetval < 0)
		logErr("getMaxColumnNameLength returns a negative value");
	    else
		logMsg("getMaxColumnNameLength returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxColumnNameLength is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxColumnNameLength is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxColumnsInGroupBy
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getMaxColumnsInGroupBy() method must return a integer value; the value
     * representing the maximum number of columns in a GROUP BY clause; 0 if
     * there is no limit or the limit is unknown. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxColumnsInGroupBy() method on that object. It
     * should return an integer value.
     */
    @Test
    public void testGetMaxColumnsInGroupBy() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxColumnsInGroupBy");
	    // invoke getMaxColumnsInGroupBy method
	    int nRetval = dbmd.getMaxColumnsInGroupBy();
	    if (nRetval < 0)
		logErr("getMaxColumnsInGroupBy returns a negative value");
	    else
		logMsg("getMaxColumnsInGroupBy returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxColumnsInGroupBy is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxColumnsInGroupBy is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxColumnsInIndex
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getMaxColumnsInIndex()
     * method must return a integer value; the value representing the maximum
     * number of columns in Index; 0 if there is no limit or the limit is
     * unknown. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxColumnsInIndex() method on that object. It
     * should return an integer value.
     */
    @Test
    public void testGetMaxColumnsInIndex() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxColumnsInIndex");
	    // invoke getMaxColumnsInIndex method
	    int nRetval = dbmd.getMaxColumnsInIndex();
	    if (nRetval < 0)
		logErr("getMaxColumnsInIndex returns a negative value");
	    else
		logMsg("getMaxColumnsInIndex returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxColumnsInIndex is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxColumnsInIndex is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxColumnsInOrderBy
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getMaxColumnsInOrderBy() method must return a integer value; the value
     * representing the maximum number of columns in a ORDER BY clause; 0 if
     * there is no limit or the limit is unknown. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxColumnsInOrderBy() method on that object. It
     * should return an integer value.
     */
    @Test
    public void testGetMaxColumnsInOrderBy() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxColumnsInOrderBy");
	    // invoke getMaxColumnsInOrderBy method
	    int nRetval = dbmd.getMaxColumnsInOrderBy();
	    if (nRetval < 0)
		logErr("getMaxColumnsInOrderBy returns a negative value");
	    else
		logMsg("getMaxColumnsInOrderBy returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxColumnsInOrderBy is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxColumnsInOrderBy is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxColumnsInSelect
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getMaxColumnsInSelect()
     * method must return a integer value; the value representing the maximum
     * number of columns in a SELECT list; 0 if there is no limit or the limit
     * is unknown. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxColumnsInSelect() method on that object. It
     * should return an integer value.
     */
    @Test
    public void testGetMaxColumnsInSelect() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxColumnsInSelect");
	    // invoke getMaxColumnsInSelect method
	    int nRetval = dbmd.getMaxColumnsInSelect();
	    if (nRetval < 0)
		logErr("getMaxColumnsInSelect returns a negative value");
	    else
		logMsg("getMaxColumnsInSelect returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxColumnsInSelect is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxColumnsInSelect is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxColumnsInTable
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getMaxColumnsInTable()
     * method must return a integer value; the value representing the maximum
     * number of columns in a Table; 0 if there is no limit or the limit is
     * unknown. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxColumnsInTable() method on that object. It
     * should return an integer value.
     */
    @Test
    public void testGetMaxColumnsInTable() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxColumnsInTable");
	    // invoke getMaxColumnsInTable method
	    int nRetval = dbmd.getMaxColumnsInTable();
	    if (nRetval < 0)
		logErr("getMaxColumnsInTable returns a negative value");
	    else
		logMsg("getMaxColumnsInTable returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxColumnsInTable is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxColumnsInTable is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxConnections
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getMaxConnections()
     * method must return a integer value; the value representing the maximum
     * number of active connections at a time in a database; 0 if there is no
     * limit or the limit is unknown. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxConnections() method on that object. It
     * should return an integer value
     */
    @Test
    public void testGetMaxConnections() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxConnections");
	    // invoke getMaxConnections method
	    int nRetval = dbmd.getMaxConnections();
	    if (nRetval < 0)
		logErr("getMaxConnections returns a negative value");
	    else
		logMsg("getMaxConnections returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxConnections is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxConnections is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxCursorNameLength
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getMaxCursorNameLength() method must return a integer value; the value
     * representing the maximum cursor name length in bytes; 0 if there is no
     * limit or the limit is unknown. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxCursorNameLength() method on that object. It
     * should return an integer value
     */
    @Test
    public void testGetMaxCursorNameLength() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxCursorNameLength");
	    // invoke getMaxCursorNameLength method
	    int nRetval = dbmd.getMaxCursorNameLength();
	    if (nRetval < 0)
		logErr("getMaxCursorNameLength returns a negative value");
	    else
		logMsg("getMaxCursorNameLength returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxCursorNameLength is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxCursorNameLength is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxIndexLength
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getMaxIndexLength()
     * method must return a integer value; the value representing the maximum
     * index length in bytes; 0 if there is no limit or the limit is unknown.
     * (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxIndexLength() method on that object. It
     * should return an integer value
     */
    @Test
    public void testGetMaxIndexLength() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxIndexLength");
	    // invoke getMaxIndexLength method
	    int nRetval = dbmd.getMaxIndexLength();
	    if (nRetval < 0)
		logErr("getMaxIndexLength returns a negative value");
	    else
		logMsg("getMaxIndexLength returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxIndexLength is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxIndexLength is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxSchemaNameLength
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getMaxSchemaNameLength() method must return a integer value; the value
     * representing the maximum schema name length that is allowed; 0 if there
     * is no limit or the limit is unknown. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxSchemaNameLength() method on that object. It
     * should return an integer value.
     */
    @Test
    public void testGetMaxSchemaNameLength() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxSchemaNameLength");
	    // invoke getMaxSchemaNameLength method
	    int nRetval = dbmd.getMaxSchemaNameLength();
	    if (nRetval < 0)
		logErr("getMaxSchemaNameLength returns a negative value");
	    else
		logMsg("getMaxSchemaNameLength returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxSchemaNameLength is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxSchemaNameLength is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxProcedureNameLength
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getMaxProcedureNameLength() method must return a integer value; the value
     * representing the maximum procedure name length that is allowed; 0 if
     * there is no limit or the limit is unknown. (See JDK 1.2.2 API
     * documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxProcedureNameLength() method on that object.
     * It should return an integer value.
     */
    @Test
    public void testGetMaxProcedureNameLength() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxProcedureNameLength");
	    // invoke getMaxProcedureNameLength method
	    int nRetval = dbmd.getMaxProcedureNameLength();
	    if (nRetval < 0)
		logErr("getMaxProcedureNameLength returns a negative value");
	    else
		logMsg("getMaxProcedureNameLength returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxProcedureNameLength is Failed!",
		    sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxProcedureNameLength is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxCatalogNameLength
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The
     * getMaxCatalogNameLength() method must return an integer value; the value
     * representing the maximum catalog name length that is allowed; 0 if there
     * is no limit or the limit is unknown. (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxCatalogNameLength() method on that object. It
     * should return an integer value.
     */
    @Test
    public void testGetMaxCatalogNameLength() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxCatalogNameLength");
	    // invoke getMaxCatalogNameLength method
	    int nRetval = dbmd.getMaxCatalogNameLength();
	    if (nRetval < 0)
		logErr("getMaxCatalogNameLength returns a negative value");
	    else
		logMsg("getMaxCatalogNameLength returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxCatalogNameLength is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxCatalogNameLength is Failed!", e);
	}
    }

    /*
     * @testName: testGetMaxRowSize
     * 
     * @assertion: The DatabaseMetaData provides information about the database.
     * (See section 15.1 of JDBC 2.0 API Reference & Tutorial 2nd edition)
     * 
     * A driver must provide full support for DatabaseMetaData and
     * ResultSetMetaData. This implies that all of the methods in the
     * DatabaseMetaData interface must be implemented and must behave as
     * specified in the JDBC 1.0 and 2.0 specifications. None of the methods in
     * DatabaseMetaData and ResultSetMetaData may throw an exception because
     * they are not implemented. (See section 6.2.2.3 of Java2 Platform
     * Enterprise Edition (J2EE) Specification v1.2) The getMaxRowSize() method
     * must return a integer value; the value representing the maximum length of
     * a single row in bytes; 0 if there is no limit or the limit is unknown.
     * (See JDK 1.2.2 API documentation)
     * 
     * @test_Strategy: Get a DatabaseMetadata object from the connection to the
     * database and call the getMaxRowSize() method on that object. It should
     * return an integer value
     */
    @Test
    public void testGetMaxRowSize() throws Exception
    {
	try
	{
	    logMsg("Calling DatabaseMetaData.getMaxRowSize");
	    // invoke getMaxRowSize method
	    int nRetval = dbmd.getMaxRowSize();
	    if (nRetval < 0)
		logErr("getMaxRowSize returns a negative value");
	    else
		logMsg("getMaxRowSize returns " + nRetval);
	}
	catch (SQLException sqle)
	{
	    logErr("SQL Exception " + sqle.getMessage());
	    throw new Exception("Call to getMaxRowSize is Failed!", sqle);
	}
	catch (Exception e)
	{
	    logErr("Unexpected Exception " + e.getMessage());
	    throw new Exception("Call to getMaxRowSize is Failed!", e);
	}
    }

    /* cleanup */
    @AfterClass
    public static void cleanup() throws Exception
    {
	try
	{
	    // Close the database
//	    dbSch.destroyData(conn);
	    dbSch.dbUnConnect(conn);
	    logMsg("Cleanup ok;");
	}
	catch (Exception e)
	{
	    logErr("An error occurred while closing the database connection");
	}
    }
}
